package com.demo.chapter3lambda;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

import com.demo.domain.Apple;

/**比较器复合
 * @author dell
 *
 */
public class ComparatorComposite {

	public void demo(){
		List<Apple> apples = Arrays.asList(new Apple(100), new Apple(150), new Apple(90), new Apple(120));
		//thenComparing当第一个排序有一样的值时，可以继续按第二个标识排序
		apples.sort(Comparator.comparing(Apple::getWeight).reversed().thenComparing(Apple::getColor));
	}

}
